package com.five.controller;

import com.five.vo.BaseResultVO;

/**
 * @author: star
 * @Date: 2021-05-18 20:17
 */
public class BaseController {

    /**
     * 业务处理成功返回
     *
     * @param data 返回业务数据对象
     */
    protected BaseResultVO successResp(Object data) {
        //构建标准返回内容
        BaseResultVO result = new BaseResultVO();
        result.setCode(BaseResultVO.Code.SUCCESS.getValue());
        result.setData(data);
        return result;
    }

    /**
     * 业务处理成功返回提示信息
     * @param msg 提示信息
     * @return 提示信息
     */
    protected BaseResultVO successRespWithMessage(String msg) {
        //构建标准返回内容
        BaseResultVO result = new BaseResultVO();
        result.setCode(BaseResultVO.Code.SUCCESS.getValue());
        result.setMessage(msg);
        return result;
    }

    /**
     * 业务处理失败返回
     *
     * @param errorMsg 失败提示信息
     */
    protected BaseResultVO errorResp(String errorMsg) {
        //构建标准返回内容
        BaseResultVO result = new BaseResultVO();
        result.setCode(BaseResultVO.Code.FAILED.getValue());
        result.setMessage(errorMsg);
        return result;
    }
}
